package com.sc.VenusQueryBeta.presenter.home.tabs;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.home.tabs.YuDingContract;
import com.sc.VenusQueryBeta.model.bean.home.OrderServiceBean;
import com.sc.VenusQueryBeta.model.home.tabs.YuDingModel;

import io.reactivex.functions.Consumer;

/**
 * Created by SC-02 on 2018/9/19.
 * 预订服务presenter
 */

public class YuDingPresenter extends YuDingContract.YuDingPresenter {

    public static YuDingPresenter newInstance() {
        return new YuDingPresenter();
    }

    @Override
    protected YuDingContract.IYuDingModel getModel() {
        return YuDingModel.newInstance();
    }

    @Override
    public void onStart() {

    }

    @Override
    public void loadLatestList() {

    }

    @Override
    public void loadMoreList() {

    }

    @Override
    public void onItemClick(int position, Object item) {

    }

    @Override
    public void getOrderServiceData() {
        if (mIView == null||mIModel==null) {
            return;
        }
        mRxManager.register(mIModel.getorderService().subscribe(new Consumer<OrderServiceBean>() {
            @Override
            public void accept(OrderServiceBean orderServiceBean) throws Exception {
//
                mIView.showOrderServiceDataSuccess(orderServiceBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("error="+throwable.getMessage());
//                if (mIView != null)
//                    return;
                mIView.showToast("Network error.");
                mIView.showNetworkError();
            }
        }));
    }
}
